﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.ComponentModel;
using log4net;

namespace ThreeByte.ActiveDeck.AddIn.Content.UserResponse
{
    /// <summary>
    /// Interaction logic for CategoriesItemElement2.xaml
    /// </summary>
    public partial class CategoriesItemElement2 : UserControl//, INotifyPropertyChanged
    {
        private static readonly ILog log = LogManager.GetLogger(typeof(CategoriesItemElement2));

        public CategoriesItemElement2() {
            log.Debug("Construct CategoriesItemElement2");
            InitializeComponent();
            log.Debug("Initialization Complete");
        }

        //public event PropertyChangedEventHandler PropertyChanged;

        //private void NotifyPropertyChanged(String info) {
        //    if(PropertyChanged != null) {
        //        PropertyChanged(this, new PropertyChangedEventArgs(info));
        //    }
        //}


        #region Dependency Properties
        public static readonly DependencyProperty WordProperty = DependencyProperty.Register("Word",
            typeof(string), typeof(CategoriesItemElement2));

        public string Word {
            get {
                return (string)GetValue(WordProperty);
            }
            set {
                SetValue(WordProperty, value);
            }
        }

        public static readonly DependencyProperty PercentProperty = DependencyProperty.Register("Percent",
            typeof(int), typeof(CategoriesItemElement2));

        public int Percent {
            get {
                return (int)GetValue(PercentProperty);
            }
            set {
                int clamped = Math.Min(100, Math.Max(0, value));
                SetValue(PercentProperty, clamped);
            }
        }

        public static readonly DependencyProperty ColorProperty = DependencyProperty.Register("Color",
            typeof(SolidColorBrush), typeof(CategoriesItemElement2), new PropertyMetadata(ColorChanged));

		public static readonly DependencyProperty ColorInvertProperty = DependencyProperty.Register("ColorInvert",
            typeof(SolidColorBrush), typeof(CategoriesItemElement2), new PropertyMetadata(ColorChanged));

		
        public SolidColorBrush Color {
            get {
                return (SolidColorBrush)GetValue(ColorProperty);
            }
            set {
                SetValue(ColorProperty, value);
                //NotifyPropertyChanged("Color");
            }
        }

		public SolidColorBrush ColorInvert {
            get {
                return (SolidColorBrush)GetValue(ColorInvertProperty);
            }
            set {
                SetValue(ColorInvertProperty, value);
                //NotifyPropertyChanged("ColorInvert");
            }
        }
        private static void ColorChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e) {
            //TOOD: Reorganize/Resize/Recolor
            //PictureController controller = (PictureController)obj;
            //controller.ResetDataContext();
        }

        #endregion


    }
}
